package com.blb.io;

public class CloneDemo {

    public static void main(String[] args) {
        Student student = new Student("0001","李四",19);
        try {
            //克隆对象
            Student student1 = (Student) student.clone();
            System.out.println(student);
            System.out.println(student1);
            System.out.println(student == student1);
            student1.getAddress().setCity("北京");
            student.sayHi();
            student1.sayHi();
            System.out.println(student.getAddress() == student1.getAddress());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    }
}
